package tools.packet;

import client.MapleCharacter;
import client.MapleClient;
import client.PartTimeJob;
import constants.GameConstants;
import constants.JobConstants;
import constants.ServerConstants;
import handling.SendPacketOpcode;
import handling.login.LoginServer;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
import server.Randomizer;
import server.ServerProperties;
import tools.DateUtil;
import tools.HexTool;
import tools.MaplePacketCreator;
import tools.data.MaplePacketLittleEndianWriter;

public class LoginPacket {

    private static final Logger log = Logger.getLogger(LoginPacket.class);

    public static byte[] getHello(short mapleVersion, byte[] sendIv, byte[] recvIv, boolean testServer) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(15 + ServerConstants.MAPLE_PATCH.length());

        mplew.writeShort(13 + ServerConstants.MAPLE_PATCH.length());
        byte[] 假ivRecv = {70, 114, 122, 82};
        byte[] 假ivSend = {82, 48, 120, 115};
        假ivRecv[3] = ((byte) (int) (Math.random() * 255.0D));
        假ivSend[3] = ((byte) (int) (Math.random() * 255.0D));
        byte[] 假ivRecv1 = {70, 114, 122, 82};
        byte[] 假ivSend1 = {82, 48, 120, 115};
        假ivRecv1[3] = ((byte) (int) (Math.random() * 255.0D));
        假ivSend1[3] = ((byte) (int) (Math.random() * 255.0D));
        byte[] 假ivRecv2 = {70, 114, 122, 82};
        byte[] 假ivSend2 = {82, 48, 120, 115};
        假ivRecv2[3] = ((byte) (int) (Math.random() * 255.0D));
        假ivSend2[3] = ((byte) (int) (Math.random() * 255.0D));
        mplew.writeShort(mapleVersion);
        mplew.writeMapleAsciiString(ServerConstants.MAPLE_PATCH);
        mplew.writeMapleAsciiString("http://mxd.sdo.com/");
        mplew.write(假ivRecv);
        mplew.write(假ivSend1);
        mplew.write(recvIv);
        mplew.write(假ivSend);
        mplew.write(recvIv);
        mplew.write(假ivSend2);
        mplew.write(假ivRecv1);
        mplew.write(sendIv);
        mplew.write(假ivRecv2);
        mplew.write(假ivSend);
        mplew.write(recvIv);
        mplew.write(sendIv);
        mplew.write(假ivRecv1);
        mplew.write(假ivSend2);
        mplew.write(7);
        
        return mplew.getPacket();
    }

public static byte[] getcs() {
      MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
      mplew.write(HexTool.getByteArrayFromHexString("39 00 01"));
      return mplew.getPacket();
}
public static byte[] getseverlist_start_end() {
      MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
      mplew.write(HexTool.getByteArrayFromHexString("03 00 00"));
      return mplew.getPacket();
}
    public static byte[] getHello(short mapleVersion, byte[] sendIv, byte[] recvIv) {
        //V131
        //0F 00 
        //83 00 
        //01 00 32 
        //49 1F 1C 23
        //DC 65 A4 6A 
        //04 00   
        
        
        //0F 00 83 00 01 00 32 49 1F 1C 23 DC 65 A4 6A 04 00
        //0F 00 84 00 01 00 31 74 32 18 0B E2 57 83 6C 04 00
         
         MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(15 + ServerConstants.MAPLE_PATCH.length());
        
        //mplew.writeShort(13 + ServerConstants.MAPLE_PATCH.length());
         mplew.writeShort(0x0F );
        mplew.writeShort(mapleVersion);
        mplew.writeMapleAsciiString(ServerConstants.MAPLE_PATCH);
        mplew.write(recvIv);
        mplew.write(sendIv);
        mplew.write(ServerConstants.MAPLE_TYPE);
        mplew.write(0x00); //131
        return mplew.getPacket();
    }

    public static byte[] getHelloN(short mapleVersion, byte[] sendIv, byte[] recvIv) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(14 + ServerConstants.MAPLE_PATCH.length());

        mplew.writeShort(0xD);//13 + ServerConstants.MAPLE_PATCH.length()
        mplew.writeShort(mapleVersion);
        mplew.writeMapleAsciiString(ServerConstants.MAPLE_PATCH);
        mplew.write(recvIv);
        mplew.write(sendIv[0]);
        mplew.write(sendIv[1]+10);
        mplew.write(sendIv[2]+15);
        mplew.write(sendIv[3]+20);
       // mplew.write(sendIv);
        mplew.write(ServerConstants.MAPLE_TYPE);

        return mplew.getPacket();
    }

    public static byte[] getPing() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(2);

        mplew.writeShort(SendPacketOpcode.PING.getValue());

        return mplew.getPacket();
    }


    /*
     public static byte[] getLoginAUTH()
     {
     MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(13);
     mplew.writeShort(SendPacketOpcode.LOGIN_AUTH.getValue());
     int rand = Randomizer.nextInt(10);
     if (rand > 5) {
     rand = 4;
     }
     else if (rand > 2) {
     rand = 2;
     }
     mplew.writeMapleAsciiString(new StringBuilder().append("MapLogin1").append(rand == 0 ? "1" : Integer.valueOf(rand)).toString());
     // mplew.writeMapleAsciiString(new StringBuilder().append(ServerProperties.getProperty("world.MapLogin") != null ? Integer.parseInt(ServerProperties.getProperty("world.MapLogin")) : "MapLogin").append(rand == 0 ? "1" : Integer.valueOf(rand)).toString());
     mplew.writeInt(DateUtil.getTime());

     return mplew.getPacket();
     }
     */
    public static byte[] getLoginAUTH() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        
        mplew.writeShort(SendPacketOpcode.LOGIN_AUTH.getValue());
        String[] a = {"MapLogin", "MapLogin1", "MapLogin2", "MapLogin3"};
        mplew.writeMapleAsciiString(a[(int) (Math.random() * a.length)]);
        mplew.writeInt(DateUtil.getTime());

        return mplew.getPacket();
        //35 00 09 00 4D 61 70 4C 6F 67 69 6E 32 F0 0D 2A 78
        /*MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        
        mplew.write(HexTool.getByteArrayFromHexString("35 00 09 00 4D 61 70 4C 6F 67 69 6E 32 F0 0D 2A 78"));
        return mplew.getPacket();*/
    }

    public static byte[] StrangeDATA() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.RSA_KEY.getValue());

        mplew.writeMapleAsciiString("30819F300D06092A864886F70D010101050003818D0030818902818100994F4E66B003A7843C944E67BE4375203DAA203C676908E59839C9BADE95F53E848AAFE61DB9C09E80F48675CA2696F4E897B7F18CCB6398D221C4EC5823D11CA1FB9764A78F84711B8B6FCA9F01B171A51EC66C02CDA9308887CEE8E59C4FF0B146BF71F697EB11EDCEBFCE02FB0101A7076A3FEB64F6F6022C8417EB6B87270203010001");

        return mplew.getPacket();
    }

    public static byte[] getCustomEncryption() {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(26);

        mplew.writeShort(SendPacketOpcode.LOGIN_STATUS.getValue());
        mplew.writeLong(611816276193195499L);
        mplew.writeLong(1877319832L);
        mplew.writeLong(202227478981090217L);
        return mplew.getPacket();
    }

    public static byte[] licenseResult() {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.LICENSE_RESULT.getValue());
        mplew.write(1);

        return mplew.getPacket();
    }

    public static byte[] genderNeeded(MapleClient c) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(3);

        mplew.writeShort(SendPacketOpcode.CHOOSE_GENDER.getValue());
        mplew.writeMapleAsciiString(c.getAccountName());

        return mplew.getPacket();
    }

    public static byte[] genderChanged(MapleClient c) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(3);

        mplew.writeShort(SendPacketOpcode.GENDER_SET.getValue());
        mplew.write(0);
        mplew.writeMapleAsciiString(c.getAccountName());
        mplew.writeMapleAsciiString(String.valueOf(c.getAccID()));

        return mplew.getPacket();
    }

    public static byte[] getLoginFailed(int reason) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(16);

        mplew.writeShort(SendPacketOpcode.LOGIN_STATUS.getValue());
        mplew.write(reason);
        if (reason == 84) {
            mplew.writeLong(PacketHelper.getTime(-2L));
        } else if (reason == 7) {
            mplew.writeZeroBytes(5);
        }
        return mplew.getPacket();
    }

    public static byte[] getPermBan(byte reason) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(16);

        mplew.writeShort(SendPacketOpcode.LOGIN_STATUS.getValue());
        mplew.writeShort(2);
        mplew.write(0);
        mplew.writeShort(reason);
        mplew.write(HexTool.getByteArrayFromHexString("01 01 01 01 00"));

        return mplew.getPacket();
    }

    public static byte[] getTempBan(long timestampTill, byte reason) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(17);

        mplew.writeShort(SendPacketOpcode.LOGIN_STATUS.getValue());
        mplew.writeShort(2);
        mplew.writeInt(0);
        mplew.write(reason);
        mplew.writeLong(timestampTill);

        return mplew.getPacket();
    }

    public static byte[] getAuthSuccessRequest(MapleClient client) {
        if (ServerProperties.ShowPacket()) {
            log.info(("调用: ") + (new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        //
        
        
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.LOGIN_STATUS.getValue());
        mplew.write(0x00);
        mplew.writeMapleAsciiString(client.getAccountName());
        mplew.writeInt(0);  
        mplew.write(HexTool.getByteArrayFromHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 8C E0 67 3B 77 D1 01 00 00 00 00 00 00 00 00 00 00 00 01 01 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 00 01 00 01 01 00 01 01 00 00 01 00 01 01 00 01 01 00 00 01 00 01 01 00 00 01 00 01 01 00 01 01 00 01 01 00 00 01 00 01 01 00 01 01 00 00 01 00 00 FF FF FF FF "));
        mplew.write(0x00);
        mplew.writeMapleAsciiString(String.valueOf(client.getAccID()));
        mplew.writeMapleAsciiString(client.getAccountName());
        mplew.write(HexTool.getByteArrayFromHexString("01 01 00"));

        /*mplew.writeShort(SendPacketOpcode.LOGIN_STATUS.getValue());
        mplew.write(0);
        mplew.writeInt(client.getAccID());  //角色ID
        mplew.write(client.getGender());    //性别
        mplew.write(client.isGm() ? 1 : 0);
        mplew.write(client.isGm() ? 1 : 0);

        mplew.writeInt(0);
        mplew.writeShort(0);
        mplew.write(0);
        mplew.write(2);
        mplew.write(0);

        mplew.writeLong(PacketHelper.getTime(System.currentTimeMillis()));

        mplew.writeLong(0L);
        mplew.writeShort(0);
        mplew.write(0);

        mplew.write(1);   
        mplew.write(JobConstants.jobOrder);//创建角色的顺序

        for (JobConstants.LoginJob j : JobConstants.LoginJob.values()) {
            mplew.write(j.getFlag());
            mplew.write(1);
            mplew.write(0);
         }
        
        mplew.write(1);   //登录消息窗
        
        mplew.writeMapleAsciiString(String.valueOf(client.getAccID()));
        mplew.writeMapleAsciiString(client.getAccountName());

        mplew.write(1);  //这里是身份证信息 1=不提示  0=提示身份证未注册
        mplew.writeShort(1);*/

        return mplew.getPacket();
    }

    public static byte[] deleteCharResponse(int cid, int state) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.DELETE_CHAR_RESPONSE.getValue());
        mplew.writeInt(cid);
        mplew.write(state);

        return mplew.getPacket();
    }

    public static byte[] secondPwError(byte mode) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(3);

        mplew.writeShort(SendPacketOpcode.SECONDPW_ERROR.getValue());
        mplew.write(mode);

        return mplew.getPacket();
    }

    public static byte[] enableRecommended() {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.ENABLE_RECOMMENDED.getValue());
        mplew.write(0);
        return mplew.getPacket();
    }

    public static byte[] sendRecommended(int world, String message) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.SEND_RECOMMENDED.getValue());
        mplew.write((message != null) && (GameConstants.GMS) ? 1 : 0);
        if ((message != null) && (GameConstants.GMS)) {
            mplew.writeInt(world);
            mplew.writeMapleAsciiString(message);
        }
        return mplew.getPacket();
    }

    public static byte[] getServerList(int serverId, Map<Integer, Integer> channelLoad) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
       //01 00 02 00 02 00 02 00 00 64 00 64 00 04 F4 01 00 00 
        mplew.writeShort(SendPacketOpcode.SERVERLIST.getValue());
        mplew.writeShort(serverId);  
        String worldName = LoginServer.getTrueServerName();
        mplew.writeMapleAsciiString(worldName);
        mplew.write(LoginServer.getFlag());
        mplew.writeMapleAsciiString(LoginServer.getEventMessage());
        mplew.writeShort(100);
        mplew.writeShort(100);
        int lastChannel = 1;
        Set channels = channelLoad.keySet();
        for (int i = 30; i > 0; i--) {
            if (channels.contains(i)) {
                lastChannel = i;
                break;
            }
        }
        mplew.write(lastChannel);
        mplew.writeInt(500);

        for (int i = 1; i <= lastChannel; i++) {
            int load;
///*     */       int load;
            if (channels.contains(i)) {
                load = (channelLoad.get(i));
            } else {
                load = 1200;
            }
            //mplew.writeMapleAsciiString(new StringBuilder().append(worldName).append("-").append(i).toString());
            mplew.writeMapleAsciiString(worldName + "-" + i);
            mplew.writeInt(load);
            mplew.write(serverId);
            mplew.writeShort(i - 1);
        }
        //System.out.println("未完成的:"+HexTool.getByteArrayFromHexString("4E D2 37 5B FB 4C 7C D4 6D B4 48 A7 55 48 9F 44 F9 5E 3C C2 7F 38 74 B4 08 E2 A5 2D D0 93 C4 02 01 3D AE F0 F7 9A A5"));
        mplew.writeLong(0);
        //mplew.write(HexTool.getByteArrayFromHexString("4E D2 37 5B FB 4C 7C D4 6D B4 48 A7 55 48 9F 44 F9 5E 3C C2 7F 38 74 B4 08 E2 A5 2D D0 93 C4 02 01 3D AE F0 F7 9A A5"));   
        return mplew.getPacket();
    }

    public static byte[] getEndOfServerList() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SERVERLIST.getValue());
        mplew.write(255);
        mplew.write(255);
        mplew.writeLong(PacketHelper.getTime(System.currentTimeMillis()));

        mplew.write(0);
        mplew.write(0);
        return mplew.getPacket();
    }

    public static byte[] getLoginWelcome() {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        return MaplePacketCreator.spawnFlags(null);
    }
    public static byte[] getLoginWelcome2() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.write(HexTool.getByteArrayFromHexString("3C 00 00"));
        return mplew.getPacket();
    }
    public static byte[] getServerStatus(int status) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SERVERSTATUS.getValue());
        mplew.write(status);

        return mplew.getPacket();
    }

    public static byte[] EventCheck() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.EVENT_CHECK.getValue());

        //mplew.write(HexTool.getByteArrayFromHexString("00 05 00 00 10 40 00 46 E5 58 00 57 F5 98 00 04 00 00 00 5F F5 98 00 04 00 00 00 6C F5 98 00 94 CA 07 00 D0 C3 A0 00 1C 16 01 00"));
        //发送这个会出现网吧mplew.write(HexTool.getByteArrayFromHexString("70 00 01 00 32 46 72 7A 85 52 30 78 C5 04 F7 3A F4 3A 74 75 29"));
        mplew.write(0);
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    public static byte[] getChannelSelected() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CHANNEL_SELECTED.getValue());
        mplew.writeInt(3);

        return mplew.getPacket();
    }

    public static byte[] getCharList(String secondpw, List<MapleCharacter> chars, int charslots) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CHARLIST.getValue());
        mplew.write(0x00);
        mplew.writeMapleAsciiString("normal");
        mplew.write(0x04);
        mplew.writeLong(0);
        mplew.writeLong(PacketHelper.getTime(System.currentTimeMillis()));
        mplew.write(0x00);
        mplew.write(chars.size());


        for (MapleCharacter chr : chars) {
            addCharEntry(mplew, chr, false);
            mplew.write(0);
        }
        mplew.writeShort(0);
        mplew.writeInt(0);
        mplew.writeLong(charslots);
        mplew.writeInt(-1);
        mplew.writeLong(2365862394066991035L);
        mplew.writeShort(0);
        mplew.writeInt(DateUtil.getTime());
        /*
        mplew.write(chars.size());
        for (MapleCharacter chr : chars) {
            addCharEntry(mplew, chr, false);
            mplew.write(0);
        }

        mplew.writeShort(0);
        mplew.writeLong(charslots);
        mplew.writeInt(-1);
        mplew.writeLong(PacketHelper.getTime(System.currentTimeMillis()));
        mplew.write(0);
        mplew.writeInt(DateUtil.getTime());
        */
        return mplew.getPacket();
    }

    public static byte[] addNewCharEntry(MapleCharacter chr, boolean worked) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.ADD_NEW_CHAR_ENTRY.getValue());
        mplew.write(worked ? 0 : 1);
        addCharEntry(mplew, chr, false);

        return mplew.getPacket();
    }

    public static byte[] charNameResponse(String charname, boolean nameUsed) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CHAR_NAME_RESPONSE.getValue());
        mplew.writeMapleAsciiString(charname);
        mplew.write(nameUsed ? 1 : 0);

        return mplew.getPacket();
    }

    public static byte[] charNameResponse(String charname, byte type) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CHAR_NAME_RESPONSE.getValue());
        mplew.writeMapleAsciiString(charname);
        mplew.write(type);

        return mplew.getPacket();
    }

    private static void addCharEntry(MaplePacketLittleEndianWriter mplew, MapleCharacter chr, boolean viewAll) {
        PacketHelper.addCharStats(mplew, chr);
        PacketHelper.addCharLook(mplew, chr, true, viewAll, false, true);
    }

    public static byte[] showAllCharacter(int chars) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.ALL_CHARLIST.getValue());
        mplew.write(1);
        mplew.writeInt(chars);
        mplew.writeInt(chars + (3 - chars % 3));
        return mplew.getPacket();
    }

    public static byte[] showAllCharacterInfo(int worldid, List<MapleCharacter> chars, String pic) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.ALL_CHARLIST.getValue());
        mplew.write(chars.isEmpty() ? 5 : 0);
        mplew.write(worldid);
        mplew.write(chars.size());
        for (MapleCharacter chr : chars) {
            addCharEntry(mplew, chr, true);
        }
        mplew.write(pic == null ? 0 : pic.equals("") ? 2 : 1);
        return mplew.getPacket();
    }

    public static byte[] 去头顶称号() {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.QU_CHENGHAO.getValue());
        mplew.writeZeroBytes(21);

        return mplew.getPacket();
    }

    public static byte[] 去头顶称号_0() {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.QU_CHENGHAO_0.getValue());
        for (int i = 0; i < 5; i++) {
            mplew.writeShort(0);
            mplew.write(-1);
        }

        return mplew.getPacket();
    }

    public static byte[] 去头顶称号_1(MapleCharacter chr) {
        if (ServerProperties.ShowPacket()) {
            log.info(new StringBuilder().append("调用: ").append(new java.lang.Throwable().getStackTrace()[0]).toString());
        }
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.QU_CHENGHAO_1.getValue());
        if (GameConstants.is萝莉(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("A6 1E 05 00 F4 01 00 00"));
        } else if (GameConstants.is尖兵(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("A4 1E 05 00 2C 01 00 00"));
        } else if (GameConstants.is恶魔猎手(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("B2 1E 05 00 C8 00 00 00"));
        } else if (GameConstants.is狂龙(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("A7 1E 05 00 58 02 00 00"));
        } else if (GameConstants.is骑士团(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("A2 1E 05 00 00 00 00 00"));
        } else if (GameConstants.is龙神(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("B0 1E 05 00 C8 00 00 00"));
        } else if (GameConstants.is反抗者(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("AC 1E 05 00 64 00 00 00"));
        } else if (GameConstants.is双弩精灵(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("B3 1E 05 00 2C 01 00 00"));
        } else if (GameConstants.is火炮手(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("AA 1E 05 00 BC 02 00 00"));
        } else if (GameConstants.is冒险家(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("AD 1E 05 00 C8 00 00 00"));
        } else if (GameConstants.is战神(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("AE 1E 05 00 C8 00 00 00"));
        } else if (GameConstants.is夜光(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("A5 1E 05 00 90 01 00 00"));
        } else if (GameConstants.is幻影(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("CD 23 05 00 00 00 00 00"));
        } else if (GameConstants.is米哈尔(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("D1 23 05 00 00 00 00 00"));
        } else if (GameConstants.is暗影双刀(chr.getJob())) {
            mplew.write(HexTool.getByteArrayFromHexString("CF 23 05 00 00 00 00 00"));
        }

        return mplew.getPacket();
    }

    public static byte[] updatePartTimeJob(PartTimeJob partTime) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(21);
        mplew.writeShort(SendPacketOpcode.PART_TIME.getValue());
        mplew.writeInt(partTime.getCharacterId());
        mplew.write(0);
        PacketHelper.addPartTimeJob(mplew, partTime);
        return mplew.getPacket();
    }
    
    public static byte[] 角色卡界面(int 角色卡数量) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(21);
        mplew.writeShort(SendPacketOpcode.SHOW_CHAR_CARDS.getValue());
        mplew.writeInt(角色卡数量);
        return mplew.getPacket();
    }
    public static byte[] partTimeJob(int cid, short type, long time) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.PART_TIME.getValue());
        mplew.writeInt(cid);
        mplew.write(0);
        mplew.write(type);
        //1) 0A D2 CD 01 70 59 9F EA
        //2) 0B D2 CD 01 B0 6B 9C 18
        mplew.writeReversedLong(PacketHelper.getTime(time));
        mplew.writeInt(0);
        mplew.write(0);

        return mplew.getPacket();
    }

    public static byte[] CardSlot() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.SHOW_CHAR_CARDS.getValue());
        mplew.writeInt(6);
        //System.out.println("<信息>：发送CardSlot"+HexTool.toString(mplew.getPacket()));
        return mplew.getPacket();
    }
}

/* Location:           C:\Users\文炳\Desktop\CXFBY\114Maplewing.jar
 * Qualified Name:     tools.packet.LoginPacket
 * JD-Core Version:    0.6.2
 */